<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>贷款与信用卡利息计算器</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <style>
        .gradient-bg {
            background: linear-gradient(135deg, #4f46e5 0%, #8b5cf6 100%);
        }
        .card-shadow {
            box-shadow: 0 10px 30px -5px rgba(79, 70, 229, 0.3);
        }
        .result-item {
            transition: all 0.3s ease;
        }
        .result-item:hover {
            transform: translateY(-3px);
        }
        .tab-active {
            border-bottom: 3px solid #4f46e5;
            font-weight: 600;
        }
        .slide-fade-enter-active {
            transition: all 0.3s ease;
        }
        .slide-fade-leave-active {
            transition: all 0.3s ease;
        }
        .slide-fade-enter-from,
        .slide-fade-leave-to {
            transform: translateY(10px);
            opacity: 0;
        }
    </style>
</head>
<body class="bg-gray-50 min-h-screen">
    <div class="container mx-auto px-4 py-8">
        <div class="text-center mb-10">
            <h1 class="text-4xl font-bold text-gray-800 mb-2">贷款与信用卡计算器</h1>
            <p class="text-gray-600 max-w-2xl mx-auto">计算您的每月还款额、总利息以及贷款或信用卡最低还款的还款计划</p>
        </div>

        <div class="max-w-3xl mx-auto">
            <div class="flex border-b mb-6">
                <button id="loanTab" class="px-6 py-3 text-lg font-medium text-gray-700 tab-active">贷款计算器</button>
                <button id="creditCardTab" class="px-6 py-3 text-lg font-medium text-gray-700">信用卡计算器</button>
            </div>

            <!-- 贷款计算器 -->
            <div id="loanCalculator" class="bg-white rounded-xl shadow-md p-6 mb-8 card-shadow">
                <div class="grid grid-cols-1 md:grid-cols-2 gap-6 mb-6">
                    <div>
                        <label for="loanAmount" class="block text-sm font-medium text-gray-700 mb-1">贷款金额(元)</label>
                        <div class="relative">
                            <div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
                                <span class="text-gray-500">¥</span>
                            </div>
                            <input type="number" id="loanAmount" class="pl-8 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 py-2" placeholder="10,000" value="10000">
                        </div>
                    </div>
                    <div>
                        <label for="loanInterest" class="block text-sm font-medium text-gray-700 mb-1">年利率(%)</label>
                        <div class="relative">
                            <div class="absolute inset-y-0 right-0 pr-3 flex items-center pointer-events-none">
                                <span class="text-gray-500">%</span>
                            </div>
                            <input type="number" id="loanInterest" class="pr-8 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 py-2" placeholder="5.5" value="7.5" step="0.1">
                        </div>
                    </div>
                </div>

                <div class="mb-6">
                    <label class="block text-sm font-medium text-gray-700 mb-2">贷款期限</label>
                    <div class="grid grid-cols-3 sm:grid-cols-6 gap-2">
                        <button class="loan-term-btn py-2 px-3 rounded-md border border-gray-300 bg-white text-sm font-medium text-gray-700 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-indigo-500" data-months="3">3个月</button>
                        <button class="loan-term-btn py-2 px-3 rounded-md border border-gray-300 bg-white text-sm font-medium text-gray-700 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-indigo-500" data-months="6">6个月</button>
                        <button class="loan-term-btn py-2 px-3 rounded-md border border-gray-300 bg-white text-sm font-medium text-gray-700 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-indigo-500" data-months="12">12个月</button>
                        <button class="loan-term-btn py-2 px-3 rounded-md border border-gray-300 bg-white text-sm font-medium text-gray-700 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-indigo-500" data-months="24">24个月</button>
                        <button class="loan-term-btn py-2 px-3 rounded-md border border-gray-300 bg-white text-sm font-medium text-gray-700 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-indigo-500" data-months="36">36个月</button>
                        <button class="loan-term-btn py-2 px-3 rounded-md border border-gray-300 bg-white text-sm font-medium text-gray-700 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-indigo-500" data-months="48">48个月</button>
                    </div>
                </div>

                <div class="grid grid-cols-1 md:grid-cols-3 gap-6 mb-6">
                    <div>
                        <label for="customMonths" class="block text-sm font-medium text-gray-700 mb-1">或自定义期限(月)</label>
                        <input type="number" id="customMonths" class="block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 py-2" placeholder="例如18" min="1">
                    </div>
                    <div>
                        <label class="block text-sm font-medium text-gray-700 mb-1">还款方式</label>
                        <select id="repaymentMethod" class="block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 py-2">
                            <option value="equalInstallment">等额本息</option>
                            <option value="equalPrincipal">等额本金</option>
                            <option value="equalPrincipalInterest">等本等息</option>
                        </select>
                    </div>
                    <div class="flex items-end">
                        <button id="calculateLoan" class="w-full gradient-bg text-white py-2 px-4 rounded-md hover:opacity-90 transition duration-300 flex items-center justify-center">
                            <i class="fas fa-calculator mr-2"></i> 计算
                        </button>
                    </div>
                </div>

                <div id="loanResults" class="hidden">
                    <div class="border-t pt-6">
                        <h3 class="text-lg font-medium text-gray-900 mb-4">贷款摘要</h3>
                        <div class="grid grid-cols-1 md:grid-cols-3 gap-4 mb-6">
                            <div class="result-item bg-indigo-50 rounded-lg p-4">
                                <p class="text-sm font-medium text-indigo-600">每月还款</p>
                                <p id="monthlyPayment" class="text-2xl font-bold text-gray-900">¥0.00</p>
                            </div>
                            <div class="result-item bg-indigo-50 rounded-lg p-4">
                                <p class="text-sm font-medium text-indigo-600">总利息</p>
                                <p id="totalInterest" class="text-2xl font-bold text-gray-900">¥0.00</p>
                            </div>
                            <div class="result-item bg-indigo-50 rounded-lg p-4">
                                <p class="text-sm font-medium text-indigo-600">总还款额</p>
                                <p id="totalPayment" class="text-2xl font-bold text-gray-900">¥0.00</p>
                            </div>
                        </div>

                        <h3 class="text-lg font-medium text-gray-900 mb-4">还款计划</h3>
                        <div class="overflow-x-auto">
                            <table class="min-w-full divide-y divide-gray-200">
                                <thead class="bg-gray-50">
                                    <tr>
                                        <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">月份</th>
                                        <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">还款额</th>
                                        <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">本金</th>
                                        <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">利息</th>
                                        <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">剩余</th>
                                    </tr>
                                </thead>
                                <tbody id="loanSchedule" class="bg-white divide-y divide-gray-200">
                                    <!-- 还款计划将插入到这里 -->
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>

            <!-- 信用卡计算器 -->
            <div id="creditCardCalculator" class="bg-white rounded-xl shadow-md p-6 mb-8 card-shadow hidden">
                <div class="grid grid-cols-1 md:grid-cols-2 gap-6 mb-6">
                    <div>
                        <label for="cardBalance" class="block text-sm font-medium text-gray-700 mb-1">信用卡欠款(元)</label>
                        <div class="relative">
                            <div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
                                <span class="text-gray-500">¥</span>
                            </div>
                            <input type="number" id="cardBalance" class="pl-8 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 py-2" placeholder="5,000" value="5000">
                        </div>
                    </div>
                    <div>
                        <label for="cardInterest" class="block text-sm font-medium text-gray-700 mb-1">年利率(%)</label>
                        <div class="relative">
                            <div class="absolute inset-y-0 right-0 pr-3 flex items-center pointer-events-none">
                                <span class="text-gray-500">%</span>
                            </div>
                            <input type="number" id="cardInterest" class="pr-8 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 py-2" placeholder="18.9" value="18.9" step="0.1">
                        </div>
                    </div>
                </div>

                <div class="grid grid-cols-1 md:grid-cols-2 gap-6 mb-6">
                    <div>
                        <label for="minPaymentPercent" class="block text-sm font-medium text-gray-700 mb-1">最低还款比例(%)</label>
                        <div class="relative">
                            <div class="absolute inset-y-0 right-0 pr-3 flex items-center pointer-events-none">
                                <span class="text-gray-500">%</span>
                            </div>
                            <input type="number" id="minPaymentPercent" class="pr-8 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 py-2" placeholder="3" value="3" step="0.1">
                        </div>
                    </div>
                    <div>
                        <label for="minPaymentFixed" class="block text-sm font-medium text-gray-700 mb-1">或固定最低还款(元)</label>
                        <div class="relative">
                            <div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
                                <span class="text-gray-500">¥</span>
                            </div>
                            <input type="number" id="minPaymentFixed" class="pl-8 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 py-2" placeholder="25">
                        </div>
                    </div>
                </div>

                <div class="mb-6">
                    <label for="additionalPayment" class="block text-sm font-medium text-gray-700 mb-1">每月额外还款(元)</label>
                    <div class="relative">
                        <div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
                            <span class="text-gray-500">¥</span>
                        </div>
                        <input type="number" id="additionalPayment" class="pl-8 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 py-2" placeholder="0" value="0">
                    </div>
                </div>

                <div class="grid grid-cols-1 md:grid-cols-2 gap-6 mb-6">
                    <div>
                        <label class="block text-sm font-medium text-gray-700 mb-1">还款方式</label>
                        <select id="cardRepaymentMethod" class="block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 py-2">
                            <option value="equalInstallment">等额本息</option>
                            <option value="equalPrincipal">等额本金</option>
                            <option value="equalPrincipalInterest">等本等息</option>
                        </select>
                    </div>
                    <div class="flex items-end justify-center">
                        <button id="calculateCreditCard" class="w-full md:w-auto gradient-bg text-white py-2 px-6 rounded-md hover:opacity-90 transition duration-300 flex items-center justify-center">
                            <i class="fas fa-credit-card mr-2"></i> 计算最低还款
                        </button>
                    </div>
                </div>

                <div id="creditCardResults" class="hidden">
                    <div class="border-t pt-6">
                        <h3 class="text-lg font-medium text-gray-900 mb-4">信用卡摘要</h3>
                        <div class="grid grid-cols-1 md:grid-cols-3 gap-4 mb-6">
                            <div class="result-item bg-indigo-50 rounded-lg p-4">
                                <p class="text-sm font-medium text-indigo-600">还清月数</p>
                                <p id="monthsToPayOff" class="text-2xl font-bold text-gray-900">0</p>
                            </div>
                            <div class="result-item bg-indigo-50 rounded-lg p-4">
                                <p class="text-sm font-medium text-indigo-600">总利息</p>
                                <p id="cardTotalInterest" class="text-2xl font-bold text-gray-900">¥0.00</p>
                            </div>
                            <div class="result-item bg-indigo-50 rounded-lg p-4">
                                <p class="text-sm font-medium text-indigo-600">总还款额</p>
                                <p id="cardTotalPayment" class="text-2xl font-bold text-gray-900">¥0.00</p>
                            </div>
                        </div>

                        <h3 class="text-lg font-medium text-gray-900 mb-4">还款计划</h3>
                        <div class="overflow-x-auto">
                            <table class="min-w-full divide-y divide-gray-200">
                                <thead class="bg-gray-50">
                                    <tr>
                                        <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">月份</th>
                                        <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">还款额</th>
                                        <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">本金</th>
                                        <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">利息</th>
                                        <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">剩余</th>
                                    </tr>
                                </thead>
                                <tbody id="creditCardSchedule" class="bg-white divide-y divide-gray-200">
                                    <!-- 还款计划将插入到这里 -->
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <div class="mt-12 text-center text-gray-500 text-sm">
            <p>本计算器仅供参考，实际贷款条款可能因贷款机构而异。</p>
        </div>
    </div>

    <script>
        document.addEventListener('DOMContentLoaded', function() {
            // 选项卡切换
            const loanTab = document.getElementById('loanTab');
            const creditCardTab = document.getElementById('creditCardTab');
            const loanCalculator = document.getElementById('loanCalculator');
            const creditCardCalculator = document.getElementById('creditCardCalculator');

            loanTab.addEventListener('click', function() {
                loanTab.classList.add('tab-active');
                creditCardTab.classList.remove('tab-active');
                loanCalculator.classList.remove('hidden');
                creditCardCalculator.classList.add('hidden');
            });

            creditCardTab.addEventListener('click', function() {
                creditCardTab.classList.add('tab-active');
                loanTab.classList.remove('tab-active');
                creditCardCalculator.classList.remove('hidden');
                loanCalculator.classList.add('hidden');
            });

            // 贷款期限按钮
            const loanTermButtons = document.querySelectorAll('.loan-term-btn');
            const customMonthsInput = document.getElementById('customMonths');

            loanTermButtons.forEach(button => {
                button.addEventListener('click', function() {
                    // 移除所有按钮的活动类
                    loanTermButtons.forEach(btn => btn.classList.remove('bg-indigo-100', 'border-indigo-500'));

                    // 为点击的按钮添加活动类
                    this.classList.add('bg-indigo-100', 'border-indigo-500');

                    // 将自定义月份输入设置为选定的值
                    customMonthsInput.value = this.dataset.months;
                });
            });

            // 贷款计算器
            const calculateLoanBtn = document.getElementById('calculateLoan');
            const loanResults = document.getElementById('loanResults');
            const monthlyPaymentEl = document.getElementById('monthlyPayment');
            const totalInterestEl = document.getElementById('totalInterest');
            const totalPaymentEl = document.getElementById('totalPayment');
            const loanScheduleEl = document.getElementById('loanSchedule');

            calculateLoanBtn.addEventListener('click', calculateLoan);

            function calculateLoan() {
                const loanAmount = parseFloat(document.getElementById('loanAmount').value);
                const annualInterestRate = parseFloat(document.getElementById('loanInterest').value);
                const months = parseInt(document.getElementById('customMonths').value) || 12;
                const repaymentMethod = document.getElementById('repaymentMethod').value;

                if (isNaN(loanAmount) || isNaN(annualInterestRate) || isNaN(months)) {
                    alert('请输入所有字段的有效数字');
                    return;
                }

                const monthlyInterestRate = annualInterestRate / 100 / 12;
                let monthlyPayment = 0;
                let totalPayment = 0;
                let totalInterest = 0;
                let scheduleHTML = '';
                let remainingBalance = loanAmount;

                if (repaymentMethod === 'equalInstallment') {
                    // 等额本息
                    monthlyPayment = (loanAmount * monthlyInterestRate) / (1 - Math.pow(1 + monthlyInterestRate, -months));
                    totalPayment = monthlyPayment * months;
                    totalInterest = totalPayment - loanAmount;

                    for (let i = 1; i <= months; i++) {
                        const interestPayment = remainingBalance * monthlyInterestRate;
                        const principalPayment = monthlyPayment - interestPayment;
                        remainingBalance -= principalPayment;

                        if (remainingBalance < 0) remainingBalance = 0;

                        scheduleHTML += `
                            <tr>
                                <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">${i}</td>
                                <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">${monthlyPayment.toFixed(2)}</td>
                                <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">${principalPayment.toFixed(2)}</td>
                                <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">${interestPayment.toFixed(2)}</td>
                                <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">${remainingBalance.toFixed(2)}</td>
                            </tr>
                        `;
                    }
                } else if (repaymentMethod === 'equalPrincipal') {
                    // 等额本金
                    const principalPayment = loanAmount / months;
                    totalInterest = 0;

                    for (let i = 1; i <= months; i++) {
                        const interestPayment = remainingBalance * monthlyInterestRate;
                        monthlyPayment = principalPayment + interestPayment;
                        remainingBalance -= principalPayment;
                        totalInterest += interestPayment;

                        if (remainingBalance < 0) remainingBalance = 0;

                        scheduleHTML += `
                            <tr>
                                <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">${i}</td>
                                <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">${monthlyPayment.toFixed(2)}</td>
                                <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">${principalPayment.toFixed(2)}</td>
                                <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">${interestPayment.toFixed(2)}</td>
                                <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">${remainingBalance.toFixed(2)}</td>
                            </tr>
                        `;
                    }
                    totalPayment = loanAmount + totalInterest;
                } else {
                    // 等本等息
                    const principalPayment = loanAmount / months;
                    const interestPayment = loanAmount * monthlyInterestRate;
                    monthlyPayment = principalPayment + interestPayment;
                    totalInterest = interestPayment * months;
                    totalPayment = loanAmount + totalInterest;

                    for (let i = 1; i <= months; i++) {
                        remainingBalance -= principalPayment;

                        if (remainingBalance < 0) remainingBalance = 0;

                        scheduleHTML += `
                            <tr>
                                <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">${i}</td>
                                <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">${monthlyPayment.toFixed(2)}</td>
                                <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">${principalPayment.toFixed(2)}</td>
                                <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">${interestPayment.toFixed(2)}</td>
                                <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">${remainingBalance.toFixed(2)}</td>
                            </tr>
                        `;
                    }
                }

                // 显示结果
                monthlyPaymentEl.textContent = repaymentMethod === 'equalPrincipal' ? '每月不同' : '¥' + monthlyPayment.toFixed(2);
                totalInterestEl.textContent = '¥' + totalInterest.toFixed(2);
                totalPaymentEl.textContent = '¥' + totalPayment.toFixed(2);
                loanScheduleEl.innerHTML = scheduleHTML;
                loanResults.classList.remove('hidden');
            }

            // 信用卡计算器
            const calculateCreditCardBtn = document.getElementById('calculateCreditCard');
            const creditCardResults = document.getElementById('creditCardResults');
            const monthsToPayOffEl = document.getElementById('monthsToPayOff');
            const cardTotalInterestEl = document.getElementById('cardTotalInterest');
            const cardTotalPaymentEl = document.getElementById('cardTotalPayment');
            const creditCardScheduleEl = document.getElementById('creditCardSchedule');

            calculateCreditCardBtn.addEventListener('click', calculateCreditCard);

            function calculateCreditCard() {
                const balance = parseFloat(document.getElementById('cardBalance').value);
                const annualInterestRate = parseFloat(document.getElementById('cardInterest').value);
                const minPaymentPercent = parseFloat(document.getElementById('minPaymentPercent').value);
                const minPaymentFixed = parseFloat(document.getElementById('minPaymentFixed').value);
                const additionalPayment = parseFloat(document.getElementById('additionalPayment').value) || 0;

                if (isNaN(balance) || isNaN(annualInterestRate) || (isNaN(minPaymentPercent) && isNaN(minPaymentFixed))) {
                    alert('请输入所有必填字段的有效数字');
                    return;
                }

                const monthlyInterestRate = annualInterestRate / 100 / 12;
                let currentBalance = balance;
                let totalInterest = 0;
                let totalPayment = 0;
                let month = 0;
                let scheduleHTML = '';

                while (currentBalance > 0 && month < 360) { // 限制为30年，防止无限循环
                    month++;

                    // 计算最低还款额
                    let minPayment;
                    if (!isNaN(minPaymentFixed) && minPaymentFixed > 0) {
                        minPayment = minPaymentFixed;
                    } else {
                        minPayment = currentBalance * (minPaymentPercent / 100);
                    }

                    // 确保最低还款额至少为25元或余额的1%（常见信用卡规则）
                    minPayment = Math.max(minPayment, Math.min(25, currentBalance * 0.01));

                    // 添加额外还款
                    const payment = Math.min(currentBalance + (currentBalance * monthlyInterestRate), minPayment + additionalPayment);

                    // 计算本月利息
                    const interest = currentBalance * monthlyInterestRate;
                    totalInterest += interest;

                    // 计算本金还款
                    const principalPayment = payment - interest;

                    // 更新余额
                    currentBalance = currentBalance - principalPayment;

                    // 确保余额不为负
                    if (currentBalance < 0) {
                        currentBalance = 0;
                    }

                    totalPayment += payment;

                    // 添加到还款计划
                    scheduleHTML += `
                        <tr>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">${month}</td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">¥${payment.toFixed(2)}</td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">¥${principalPayment.toFixed(2)}</td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">¥${interest.toFixed(2)}</td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">¥${currentBalance.toFixed(2)}</td>
                        </tr>
                    `;
                }

                // 显示结果
                monthsToPayOffEl.textContent = month;
                cardTotalInterestEl.textContent = '¥' + totalInterest.toFixed(2);
                cardTotalPaymentEl.textContent = '¥' + totalPayment.toFixed(2);
                creditCardScheduleEl.innerHTML = scheduleHTML;
                creditCardResults.classList.remove('hidden');
            }

            // 将默认贷款期限按钮设置为12个月
            document.querySelector('.loan-term-btn[data-months="12"]').click();
        });
    </script>
</body>
</html>
